package com.tongda.menu.service;

import com.tongda.menu.R;

import android.app.Service;
import android.content.Intent;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Binder;
import android.os.IBinder;

public class SoundMusicService extends Service{
	private IBinder binder = new SoundMusicBinder();
	private SoundPool sp;
	private int sound;
	
	public class SoundMusicBinder extends Binder{
		
		public SoundMusicService getService(){
			return SoundMusicService.this;
		}
		
	}
	
	@Override
	public IBinder onBind(Intent intent) {
		return binder;
	}

	public void playSound(){
		if(sound!=0){
			sp.play(sound, 1, 1, 0, 0, 1);
		}
	}
	
	@Override
	public void onCreate() {
		super.onCreate();
		 sp = new SoundPool(10, AudioManager.STREAM_SYSTEM, 5);
		 sound = sp.load(this,R.raw.change, 1);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		sp.unload(sound);
		sp.release();
	}
}
